<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8">
<title>门店列表</title>
<link rel="stylesheet" type="text/css" href="/css/reset.css" />
<link rel="stylesheet" type="text/css" href="/css/common.css" />
<link rel="stylesheet" type="text/css" href="/css/thems.css">
<link rel="stylesheet" type="text/css" href="/css/color.css" />
 <link rel="stylesheet" type="text/css" href="/css/bootStrap.min.css">
  <link rel="stylesheet" type="text/css" href="/css/bootstrap-datetimepicker.min.css" />

<script type="text/javascript" src="/js/jquery-3.2.1.js"></script>
<script type="text/javascript">
	$(function() {
		//自适应屏幕宽度
		window.onresize = function() {
			location = location
		};

		var main_h = $(window).height();
		$('.hy_list').css('height', main_h - 45 + 'px');

		var search_w = $(window).width() - 40;
		$('.search').css('width', search_w + 'px');
		//$('.list_hy').css('width',search_w+'px');
	});
</script>
<!--框架高度设置-->
</head>

<body>
	<div id="right_ctn ">
		<div class="right_m ">
			<!--会议列表-->
			<div class="hy_list ">
				<div class="box_t ">
					<span class="name ">顺风车列表</span>

				</div>
				<!--查询-->
				<form action="/jump/toShunCar" class="navbar-form navbar-left"
					method="post ">
					&nbsp;&nbsp; <select class="form-control startProvince"
						name="startProvince">
						<option value="0">请选择出发省份</option> <#list proList as list>
						<#if startProvince??>
						<#if startProvince==list.sId>
						<option selected value="${list.sId}">${list.provincialName}</option>
						<#else>
						<option value="${list.sId}">${list.provincialName}</option>
						</#if>
						<#else>
						<option value="${list.sId}">${list.provincialName}</option>
						</#if>
						</#list>
					</select> <select class="form-control startCity" name="takeCarCity">
					
					<#if startProvince??>
					<#list liststart as list>
					<option value="${list.cityName}">${list.cityName}</option>
					</#list>
					</#if>
					
				
					</select> &nbsp;&nbsp; <select class="form-control stopProvince"
						name="stopProvince">
						<option value="0">请选择还车省份</option> <#list proList as list>
						<#if stopProvince??>
						<#if stopProvince==list.sId>
						<option selected value="${list.sId}">${list.provincialName}</option>
						<#else>
						<option value="${list.sId}">${list.provincialName}</option>
						</#if>
						<#else>
						<option value="${list.sId}">${list.provincialName}</option>
						</#if>
						</#list>
						
					</select> &nbsp;&nbsp; <select class="form-control stopCity" name="carCity">
						
					<#if stopProvince??>
					<#list liststart as list>
					<option value="${list.cityName}">${list.cityName}</option>
					</#list>
					</#if>
					</select> &nbsp;&nbsp;&nbsp;&nbsp;
					<div class="input-group">
						<input type="submit" class="btn btn-primary" name="" id=""
							value="查询" />
					</div>
				</form>
				<!--添加 start-->

				<ul class="list-inline">
					<li class="margin-top pull-right">
						<button class="btn btn-primary add" data-toggle="modal"
							data-target="#modal-add" data-backdrop="static">
							<span class="glyphicon glyphicon-plus"></span>&nbsp;添加
						</button> <!--添加模态框--> <!--添加模态框-->
					</li>
				</ul>

				<!--添加 end-->
				<!--查询-->
				<div class="space_hx ">&nbsp;</div>
				<!--列表-->
				<table class="col-md-11 table table-hover text-center">
					<tr class="bg-hui ">
						<td>编号</td>
						<td>取车城市</td>
						<td>还车城市</td>
						<td>车辆品牌</td>
						<td>车辆型号</td>
						<td>取车门店</td>
						<td>开始时间</td>
						<td>结束时间</td>
						<td>天数</td>
						<td>限定里程</td>
						<td>操作</td>
					</tr>
					<#list vehiList as list>

					<tr>
						<td>${list.hitchingrideId}</td>
					<!-- 	<td>${list.takeCarCity}</td> -->
						<td>${list.carCity}</td>
						<td>${list.vehicleBrandName}</td>
						<td>${list.carTypeName}</td>
						<td>${list.thecarstores}</td>
						<td>${list.startTime?string('yyyy-MM-dd HH-mm-ss')}</td>
						<td>${list.stopTime?string('yyyy-MM-dd HH-mm-ss')}</td>
						<td>${list.days}</td>
						<td>${list.limitedRange}</td>
						<td><span class="glyphicon glyphicon-edit bianji"
							data-toggle="modal" data-target=".mymodal" data-backdrop="static"></span>
							&nbsp; <a class="removes" href="javaScript:;"><span
								class="glyphicon glyphicon-remove color-red "></span></a></td>
					</tr>
					</#list>
				</table>
				<!--列表-->
				<!--右边底部-->
				<div class="r_foot ">
					<div class="r_foot_m ">
						<!--分页-->
						<div class="page ">
						<#if page.getHasPrevPage()>
						 <#if takeCarCity??&&carCity??&&startProvince??&&stopProvince??>
							<a href="/jump/toShunCar?pageIndex=${page.prevPage }&takeCarCity=${takeCarCity}&carCity=${carCity}&startProvince=${startProvince}&stopProvince=${stopProvince}"
									class="prev"> < </a>
						<#else>
								<a href="/jump/toShunCar?pageIndex=${page.prevPage }"
									class="prev"> < </a>
						 </#if>
						</#if>
						<#list page.groupPage as lists>
						 <#if takeCarCity??&&carCity??&&startProvince??&&stopProvince??>
						 <#if lists==page.currentPage>
						 <a style="background-color: #0099FF; color: white;"
							href="/jump/toShunCar?pageIndex=${lists}&takeCarCity=${takeCarCity}&carCity=${carCity}&startProvince=${startProvince}&stopProvince=${stopProvince}"
									class="dianji">${lists}</a>	
						<#else>
									<a 
							href="/jump/toShunCar?pageIndex=${lists}&takeCarCity=${takeCarCity}&carCity=${carCity}&startProvince=${startProvince}&stopProvince=${stopProvince}"
									class="dianji">${lists}</a>	
						 </#if>
						<#else>
						 <#if lists==page.currentPage>
						 <a style="background-color: #0099FF; color: white;"
							href="/jump/toShunCar?pageIndex=${lists}"
									class="dianji">${lists}</a>	
						<#else>
									<a 
							href="/jump/toShunCar?pageIndex=${lists}"
									class="dianji">${lists}</a>	
						 </#if>
						</#if>			
						</#list>
						<#if page.getHasNextPage()>
						
						 <#if takeCarCity??&&carCity??&&startProvince??&&stopProvince??>
						<a href="/jump/toShunCar?pageIndex=${page.nextPage }&takeCarCity=${takeCarCity}&carCity=${carCity}&startProvince=${startProvince}&stopProvince=${stopProvince}"
									class="next ">></span>
								</a>
						<#else>
								<a href="/jump/toShunCar?pageIndex=${page.nextPage}"
									class="next ">></span>
								</a>
						 </#if>
						</#if>
						</div>
						<!--分页-->
					</div>
				</div>
				</form>
				<!--右边底部-->
			</div>
			<!--会议列表-->
		</div>
	</div>
	<!-- 添加模态框-->
	<div id="modal-add" class="modal fade">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<button class="close" data-dismiss="modal">&times;</button>
					<!--head-text 标题信息-->
					<h4 class="head-text text-left">添加顺风车</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal addgrab" method="post">
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">取车城市：</span>
							<div class="col-md-8">
					
							 <select style="width: 35%;float: left" class="form-control startProvinceO"name="">
						<option value="0">请选择出发省份</option>
						 <#list proList as list>
						<option value="${list.sId}">${list.provincialName}</option>
						</#list>
					</select>
					 <select style="width: 35%;float: left;margin-left: 20px" class="form-control takeCarCity" name="takeCarCity">
					 	</select>
					 
					 	</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">还车城市：</span>
							<div class="col-md-8">
					
							 <select style="width: 35%;float: left" class="form-control stopProvinceO"name="">
						<option value="0">请选择出发省份</option>
						 <#list proList as list>
						<option value="${list.sId}">${list.provincialName}</option>
						</#list>
					
					</select>&nbsp;&nbsp;&nbsp;
					 <select style="width: 35%;float: left;margin-left: 20px" class="form-control carCity" name="carCity">
					 	</select>
					 
					 	</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">车辆品牌：</span>
							<div class="col-md-8">
					
							 <select style="width: 35%;float: left" class="form-control carBrandId"name="carBrandId">
						<option value="0">请选择车辆品牌</option>
						 <#list veh as list>
						<option value="${list.vehicleBrandId}">${list.vehicleBrandName}</option>
						</#list>
					</select>&nbsp;&nbsp;&nbsp;
					 <select style="width: 35%;float: left;;margin-left: 20px" class="form-control carModelId" name="carModelId">
					 	</select>
					 
					 	</div>
						</div>
						
						
						
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">取车门店：</span>
							<div class="col-md-6">
								<select class="form-control testselect thecarstores"
									name="thecarstores">
									 <#list storeList as list>
						<option value="${list.storeName}">${list.storeName}</option>
						</#list>

								</select>
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">开始时间</span>
					 <div class="col-md-6 controls input-append date form_datetime " data-date="2019-01-01" data-date-format="yyyy-mm-dd hh:mm:ss" data-link-field="dtp_input1">
                    <input name="startTime"  class="form-control startTime" type="text" value="" readonly>
                    <span class="add-on"><i class="icon-remove"></i></span>
					<span class="add-on"><i class="icon-th"></i></span>
                </div>
				<input type="hidden" id="dtp_input1" value="" /><br/>
						</div>

						<div class="form-group">
							<span class="col-md-2 text-center margin-top">结束时间</span>
					 <div class="col-md-6 controls input-append date form_datetime " data-date="2019-01-01" data-date-format="yyyy-mm-dd hh:mm:ss" data-link-field="dtp_input1">
                    <input  name="stopTime"  class="form-control stopTime" type="text" value="" readonly>
                    <span class="add-on"><i class="icon-remove"></i></span>
					<span class="add-on"><i class="icon-th"></i></span>
                </div>
				<input type="hidden" id="dtp_input1" value="" /><br/>
						</div>

						<div class="form-group">
							<span class="col-md-2 text-center margin-top">天数：</span>
							<div class="col-md-6">
								<input type="text" class="form-control days"
									name="days" id=""
									value="" />
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">限定里程：</span>
							<div class="col-md-6">
								<input type="text" class="form-control rackCount"
									name="limitedRange" id=""
									value="" />
							</div>
						</div>
				</div>
				<div class="modal-footer">
					<button class="btn btn-default" data-dismiss="modal">关闭</button>
					<input type="button" value="保存" class="btn btn-primary addlist" />
				</div>
				</form>
			</div>
		</div>
	</div>



	<!--模态框-->
	<!-- 修改模态框-->
	<div class="modal fade mymodal">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<button class="close" data-dismiss="modal">&times;</button>
					<!--head-text 标题信息-->
					<h4 class="head-text text-left">优惠卷详情</h4>
				</div>
				<div class="modal-body">
				<form class="form-horizontal update" method="post">
				
				<input type="hidden" class="hitchingrideId" name="hitchingrideId" value=""/>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">取车城市：</span>
							<div class="col-md-8">
					
							 <select style="width: 35%;float: left" class="form-control takeCarCityO1"name="">
						<option value="0">请选择出发省份</option>
						  <#list proList as list>
						<option value="${list.sId}">${list.provincialName}</option>
						</#list>
					</select>
					 <select style="width: 35%;float: left;margin-left: 20px" class="form-control takeCarCity1" name="takeCarCity">
					 
					 	</select>
					 
					 	</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">还车城市：</span>
							<div class="col-md-8">
					
							 <select style="width: 35%;float: left" class="form-control stopProvinceO1"name="">
						<option value="0">请选择出发省份</option>
						  <#list proList as list>
						<option value="${list.sId}">${list.provincialName}</option>
						</#list>
					</select>&nbsp;&nbsp;&nbsp;
					 <select style="width: 35%;float: left;margin-left: 20px" class="form-control carCity1" name="carCity">
					 
					 	</select>
					 
					 	</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">车辆品牌：</span>
							<div class="col-md-8">
					
							 <select style="width: 35%;float: left" class="form-control carBrandId1"name="carBrandId">
						<option value="0">请选择车辆品牌</option>
						 <#list veh as list>
						<option value="${list.vehicleBrandId}">${list.vehicleBrandName}</option>
						</#list>
					</select>&nbsp;&nbsp;&nbsp;
					 <select style="width: 35%;float: left;;margin-left: 20px" class="form-control carModelId1" name="carModelId">
					 	</select>
					 
					 	</div>
						</div>
						
						
						
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">取车门店：</span>
							<div class="col-md-6">
								<select class="form-control testselect thecarstores1"
									name="thecarstores">
									 <#list storeList as list>
						<option value="${list.storeName}">${list.storeName}</option>
						</#list>

								</select>
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">开始时间</span>
					 <div class="col-md-6 controls input-append date form_datetime " data-date="2019-01-01" data-date-format="yyyy-mm-dd hh:mm:ss" data-link-field="dtp_input1">
                    <input name="startTime"  class="form-control startTime1" type="text" value="" readonly>
                    <span class="add-on"><i class="icon-remove"></i></span>
					<span class="add-on"><i class="icon-th"></i></span>
                </div>
				<input type="hidden" id="dtp_input1" value="" /><br/>
						</div>

						<div class="form-group">
							<span class="col-md-2 text-center margin-top">结束时间</span>
					 <div class="col-md-6 controls input-append date form_datetime " data-date="2019-01-01" data-date-format="yyyy-mm-dd hh:mm:ss" data-link-field="dtp_input1">
                    <input  name="stopTime"  class="form-control stopTime1" type="text" value="" readonly>
                    <span class="add-on"><i class="icon-remove"></i></span>
					<span class="add-on"><i class="icon-th"></i></span>
                </div>
				<input type="hidden" id="dtp_input1" value="" /><br/>
						</div>

						<div class="form-group">
							<span class="col-md-2 text-center margin-top">天数：</span>
							<div class="col-md-6">
								<input type="text" class="form-control days1"
									name="days" id=""
									value="" />
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">限定里程：</span>
							<div class="col-md-6">
								<input type="text" class="form-control rackCount1"
									name="limitedRange" id=""
									value="" />
							</div>
						</div>
				</div>
				<div class="modal-footer">
					<button class="btn btn-default" data-dismiss="modal">关闭</button>
					<input type="button" value="保存" class="btn btn-primary updateList" />
				</div>
				</form>
			</div>
		</div>
	</div>
	<!--模态框-->

	<script type="text/javascript " src="/js/jquery-3.2.1.js "></script>
	<script type="text/javascript" src="/js/cityTo.js"></script>
	<script type="text/javascript " src="/js/bootstrap.js "></script>
 <script type="text/javascript " src="/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript " src="/js/bootstrap-datetimepicker.fr.js"></script> 
	<script type="text/javascript " src="/js/layer-v3.1.1/layer/layer.js "></script>
	

	<script type="text/javascript">
	
		$(function() {
			  $('.form_datetime').datetimepicker({
			        //language:  'fr',
			        weekStart: 1,
			        todayBtn:  1,
					autoclose: 1,
					todayHighlight: 1,
					startView: 2,
					forceParse: 0,
			        showMeridian: 1
			    }); 
			
			$(".startProvince").on("change",function() {
						$(".startCity").empty();
						citytoN($(this).val(),".startCity",0,null);
					})
			$(".startProvinceO").on("change",function() {
						$(".takeCarCity").empty();
						citytoN($(this).val(),".takeCarCity",0,null);
					})

			$(".stopProvince").on("change",function() {
						$(".stopCity").empty();
						citytoN($(this).val(),".stopCity",0,null);	
					})
			$(".stopProvinceO").on("change",function() {
						$(".carCity").empty();
						citytoN($(this).val(),".carCity",0,null);	
					})
					
			$(".carBrandId").on("change",function(){
				$(".carModelId").empty();
				var carBrandId = $(this).val();
				carTypeFn(carBrandId,'.carModelId',0,null);
				 
			})
			$(".stopTime").on("change",function(){
				var stopTime = $(".stopTime").val();
				var startTime = $(".startTime").val();
				if(dateDiff('D',startTime,stopTime)<1){
					layer.msg('结束日期不能小于开始日期',{time:1500,})
					$(".days").val(0);
					return false;	
				}
				$(".days").val(dateDiff('D',startTime,stopTime));
			})
			$(".startTime").on("change",function(){
				var stopTime = $(".stopTime").val();
				var startTime = $(".startTime").val();
				if(dateDiff('D',startTime,stopTime)<1){
					layer.msg('结束日期不能小于开始日期',{time:1500,})
					$(".days").val(0);
					return false;
				}
				$(".days").val(dateDiff('D',startTime,stopTime));
			})
			
			
			$(".addlist").click(function(){
				var takeCarCity = $(".takeCarCity").val();
				var carCity = $(".carCity").val();
				var carBrandId = $(".carBrandId").val();
				if(carBrandId=="0"){
					carBrandId=null;
				}
				var carModelId = $(".carModelId").val();
				var thecarstores = $(".thecarstores").val();
				var startTime = $(".startTime").val();
				var stopTime = $(".stopTime").val();
				var days = $(".days").val();
				if(parseInt(days)<1){
					layer.msg('日期天数不可小于1天',{time:1500,})
					return false;
				}
				var rackCount = $(".rackCount").val();
				
				if(judge(takeCarCity,'请选择取车城市')){
					return false;
				}
				if(judge(carCity,'请选择还车城市')){
					return false;
				}
				if(judge(carBrandId,'请选择车辆品牌')){
					return false;
				}
				if(judge(carModelId,'请选择车辆型号')){
					return false;
				}
				if(judge(thecarstores,'请选车取车门店')){
					return false;
				}
				if(judge(startTime,'请选择开始时间')){
					return false;
				}
				if(judge(stopTime,'请选择结束时间')){
					return false;
				}
				if(judge(days,'请填写天数')){
					return false;
				}
				if(judge(rackCount,'请填写限定里程')){
					return false;
				}
				var datas = $(".addgrab").serialize();
				$.ajax({
					url:"/addsVehiasshunCar",
					type:"get",
					dataType:"json",
					data:datas,
					async:true,
					success: function(data){
						if(data.msg==true){
							alert("添加成功")
							location.href="/jump/toShunCar";
						}
						else if(data.msg=="123"){
							alert("当前门店没有该车辆")
						}else{
							alert("添加失败！")
						}
					}
				})
			})
			
			//编辑
			$(".bianji").click(function(){
				var id = $(this).parents("tr").find("td").eq(0).text();
				$.ajax({
					url:"/selectToUpd",
					type:"get",
					dataType:"json",
					data:{"id":id},
					async:true,
					success: function(data){
						$(".hitchingrideId").val(id);
						var alsoProvince = $(".takeCarCityO1").find("option");
						var stopProvince = $(".stopProvinceO1").find("option")
						for (var i = 0; i < alsoProvince.length; i++) {
							if($(alsoProvince[i]).val()==data.pro0.sId){
								$(alsoProvince[i]).attr("selected","selected");
								$(".takeCarCity1").empty();
								citytoN(data.pro0.sId,$(".takeCarCity1"),1,data.city0.cityName);
							}
						}
						for (var t = 0; t < stopProvince.length; t++) {
							if($(stopProvince[t]).val()==data.pro1.sId){
								$(stopProvince[t]).attr("selected","selected");
								$(".carCity1").empty();
								citytoN(data.pro1.sId,$(".carCity1"),1,data.city1.cityName)
							}
						}			
						var carBrandId1 = $(".carBrandId1").find("option")
						
						for (var i = 0; i < carBrandId1.length; i++) {
							if($(carBrandId1[i]).val()==data.veh.carBrandId){
								$(carBrandId1[i]).attr("selected","selected");
							}
						}
						carTypeFn(data.veh.carBrandId,'.carModelId1',1,data.veh.carModelId);
												
						var thecarstores =$(".thecarstores1").find("option");
						for (var o = 0; o < thecarstores.length; o++) {
							if($(thecarstores[o]).val()==data.store.storeName){
								$(thecarstores[o]).attr("selected","selected");
							}
						}
						
						$(".startTime1").val(myFunction(data.veh.startTime));
						$(".stopTime1").val(myFunction(data.veh.stopTime));
						$(".days1").val(data.veh.days)
						$(".rackCount1").val(data.veh.limitedRange)
						
					}
				})
			})
			
			//upd
			$(".updateList").click(function(){
				var datas = $(".update").serializeArray();
				layer.load(1);
				$.ajax({
					type:"get",
					dataType:"json",
					url:"/updToVehicle",
					data:datas,
					async:true,
					success: function(data){
						if(data.msg){
							layer.msg("修改成功！",{time:1500,})
							location.href="/jump/toShunCar";
						}else{
							layer.msg("修改失败！",{time:1500,})
						}
					}
				})
			})
			
			//del
			$(".removes").click(function(){
				var id = $(this).parents("tr").find("td").eq(0).text();
				layer.load(1);
				$.ajax({
					type:"get",
					dataType:"json",
					url:"/delToVehicle",
					data:{"id":id},
					async:true,
					success: function(data){
						if(data.msg){
							layer.msg("删除成功！",{time:1500,})
							location.href="/jump/toShunCar";
						}else{
							layer.msg("删除失败！",{time:1500,})
						}
					}
				})
			})
			
		})
	</script>
</body>

</html>